﻿using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

public class MovementAsset : PlayableAsset, ITimelineClipAsset
{
    public ExposedReference<Transform> Target;
    public MovementBehaviour template;

    public ClipCaps clipCaps
    {
        get
        {
            return ClipCaps.None;
        }
    }

    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable<MovementBehaviour>.Create(graph, template);

        Transform t = Target.Resolve(playable.GetGraph().GetResolver());

        MovementBehaviour behaviour = playable.GetBehaviour();
        behaviour.Init(t);

        return playable;
    }
}
